package com.ma5d.driver.driver.controller;

import com.ma5d.driver.common.result.Result;
import com.ma5d.driver.driver.service.CosService;
import com.ma5d.driver.model.vo.driver.CosUploadVo;
import jakarta.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/cos")
public class CosController {

    @Resource
    private CosService cosService;

    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result<CosUploadVo> upload(@RequestPart("file") MultipartFile file,
                                      @RequestParam(name = "path", defaultValue = "auth") String path) {
        return Result.ok(cosService.upload(file, path));
    }
}
